package com.ocom.srvpaccess.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.dto.PerInfoDto;
import com.ocom.common.entity.human.EntityPersonnelInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface IDaoPersonnelInfo extends BaseMapper<EntityPersonnelInfo> {

    //4、根据P_ID（idnum、userID）从人员信息表personnel_info（连表部门信息表dept_info）查找userName、userCode、deptID、deptName。
    @Select("select p.p_id,p.p_name,p.p_code,p.dept_id,d.dept_name ,p.p_phone FROM personnel_info p " +
            "LEFT JOIN dept_info d ON p.com_id=d.com_id and p.dept_id = d.dept_id  where p.p_id=#{pId} and p.status=0")
    public PerInfoDto selectPerInfo(@Param("pId")Long pId);





    @Select({"<script>",
            "select p.*,c.card_no as cardNo,c.account_no as accountNo ,c.card_state as  cardState FROM personnel_info p " +
            "LEFT JOIN card_info c ON p.com_id=c.com_id and p.p_id = c.p_id  where" +
            "<foreach collection='pIds' item='item' open=' ' separator='  or ' close=' '>" +
            "p.p_id = #{item}" +
            "</foreach>"+
            "</script>"})
    public List<EntityPersonnelInfo> selectPerList(@Param("pIds")List<Long> pIds);

    //  c.card_state = 1  and
}
